﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
	[TestClass]
	public class Telegram_Calling_SEND_NDAT_Test
	{
		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test01_Equals()
		{
			{
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat = new Telegram_Calling_SEND_NDAT(eDirection.ATE_to_RCT, 0x57, true, false, null);

				{
					// completely different type - NOT equal
					object dummyObject = new object();
					Assert.IsFalse(telegramCallingSendNdat.Equals(dummyObject));
				}

				{
					// base class - NOT equal
					Telegram_Calling telegram2Compare = new Telegram_Calling(telegramCallingSendNdat.Direction, telegramCallingSendNdat.Address,
						eTelegramFunction_Calling.SEND_NDAT, telegramCallingSendNdat.FrameCountValid, telegramCallingSendNdat.FrameCountFlag);

					Assert.IsFalse(telegramCallingSendNdat.Equals(telegram2Compare));
				}

				{
					// equal
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat.Direction, telegramCallingSendNdat.Address,
						telegramCallingSendNdat.FrameCountValid, telegramCallingSendNdat.FrameCountFlag, null);

					Assert.IsTrue(telegramCallingSendNdat.Equals(telegramCallingSendNdat2Compare));
				}

				{
					// direction differs - NOT equal
					eDirection direction;
					if (telegramCallingSendNdat.Direction == eDirection.ATE_to_RCT)
					{
						direction = eDirection.RCT_to_ACE;
					}
					else
					{
						direction = eDirection.ATE_to_RCT;
					}
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(direction, telegramCallingSendNdat.Address,
						telegramCallingSendNdat.FrameCountValid, telegramCallingSendNdat.FrameCountFlag, null);
					Assert.IsFalse(telegramCallingSendNdat.Equals(telegramCallingSendNdat2Compare));
				}

				{
					// address differs - NOT equal
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat.Direction, (byte)(telegramCallingSendNdat.Address - 1),
						telegramCallingSendNdat.FrameCountValid, telegramCallingSendNdat.FrameCountFlag, null);
					Assert.IsFalse(telegramCallingSendNdat.Equals(telegramCallingSendNdat2Compare));
				}

				{
					// FrameCountFlag differs - NOT equal
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat.Direction, telegramCallingSendNdat.Address,
						telegramCallingSendNdat.FrameCountValid, !telegramCallingSendNdat.FrameCountFlag, null);
					Assert.IsFalse(telegramCallingSendNdat.Equals(telegramCallingSendNdat2Compare));
				}

				{
					// FrameCountValid differs - NOT equal
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat.Direction, telegramCallingSendNdat.Address,
						!telegramCallingSendNdat.FrameCountValid, telegramCallingSendNdat.FrameCountFlag, null);
					Assert.IsFalse(telegramCallingSendNdat.Equals(telegramCallingSendNdat2Compare));
				}
			}

			{
				// UserDataColl
				ReportType_Device reportType = new ReportType_Device(false, eReportSubType_Device.General);
				UserData userData = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportType);
				UserDataColl userDataColl = new UserDataColl();
				userDataColl.Add(userData);
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat_UserData = new Telegram_Calling_SEND_NDAT(eDirection.ATE_to_RCT, 0x57, true, false, userDataColl);


				{
					// equal properties but no user Data
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat_UserData.Direction, telegramCallingSendNdat_UserData.Address,
						telegramCallingSendNdat_UserData.FrameCountValid, telegramCallingSendNdat_UserData.FrameCountFlag, null);

					Assert.IsFalse(telegramCallingSendNdat_UserData.Equals(telegramCallingSendNdat2Compare));
				}

				{
					// equal properties but different user Data
					ReportType_Technical reportType01 = new ReportType_Technical(false, eReportSubType_Technical.Emergency_3);
					UserData userData01 = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportType01);
					UserDataColl userDataColl01 = new UserDataColl();
					userDataColl01.Add(userData01);
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat_UserData.Direction, telegramCallingSendNdat_UserData.Address,
						telegramCallingSendNdat_UserData.FrameCountValid, telegramCallingSendNdat_UserData.FrameCountFlag, userDataColl01);

					Assert.IsFalse(telegramCallingSendNdat_UserData.Equals(telegramCallingSendNdat2Compare));
				}

				{
					// equal properties equal user data
					UserDataColl userDataColl01 = new UserDataColl();
					userDataColl01.Add(userData);
					Telegram_Calling_SEND_NDAT telegramCallingSendNdat2Compare = new Telegram_Calling_SEND_NDAT(telegramCallingSendNdat_UserData.Direction, telegramCallingSendNdat_UserData.Address,
						telegramCallingSendNdat_UserData.FrameCountValid, telegramCallingSendNdat_UserData.FrameCountFlag, userDataColl01);

					Assert.IsTrue(telegramCallingSendNdat_UserData.Equals(telegramCallingSendNdat2Compare));
				}
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test02_GetHashCode()
		{
			{
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat = new Telegram_Calling_SEND_NDAT(eDirection.ATE_to_RCT, 0x07, false, true, null);
				int hashCode = telegramCallingSendNdat.GetHashCode();
			}

			{
				ReportType_Technical reportType01 = new ReportType_Technical(false, eReportSubType_Technical.Emergency_3);
				UserData userData = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportType01);
				UserDataColl userDataColl = new UserDataColl();
				userDataColl.Add(userData);
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat = new Telegram_Calling_SEND_NDAT(eDirection.ATE_to_RCT, 0x07, false, true, userDataColl);
				int hashCode = telegramCallingSendNdat.GetHashCode();
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test03_ToString()
		{
			{
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat = new Telegram_Calling_SEND_NDAT(eDirection.RCT_to_ACE, 0xa7, false, true, null);
				string stringResult = telegramCallingSendNdat.ToString();
				Assert.IsNotNull(stringResult);
			}

			{
				ReportType_Device reportType = new ReportType_Device(false, eReportSubType_Device.General);
				UserData userData = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportType);
				UserDataColl userDataColl = new UserDataColl();
				userDataColl.Add(userData);
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat = new Telegram_Calling_SEND_NDAT(eDirection.RCT_to_ACE, 0xa7, false, true, userDataColl);
				string stringResult = telegramCallingSendNdat.ToString();
				Assert.IsNotNull(stringResult);
			}

			{
				ReportType_Device reportType = new ReportType_Device(false, eReportSubType_Device.General);
				UserData userData = new UserData_02_StatusChangeReport2Confirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportType);
				UserDataColl userDataColl = new UserDataColl();
				userDataColl.Add(userData);
				UserData_01_Priority userData01 = new UserData_01_Priority(0x56);
				userDataColl.Add(userData01);
				Telegram_Calling_SEND_NDAT telegramCallingSendNdat = new Telegram_Calling_SEND_NDAT(eDirection.RCT_to_ACE, 0xa7, false, true, userDataColl);
				string stringResult = telegramCallingSendNdat.ToString();
				Assert.IsNotNull(stringResult);
			}
		}
	}
}
